# -*- coding:utf-8 -*-

__author__ = 'dong'


import requests


url_login = 'http://passport.58guakao.com/Soa/UserLogin'

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36'}

data = {
    # 'loginName': '17727766372',
    # 'pwd': 'ab654321',

    'loginName': '13726024644',
    'pwd': 'single',
}

# {"IsOk":true,"Data":{"UserId":351431,"UserToken":"468a7d00-e270-4783-918e-cdafbe5330eb","UserName":"","LV":2,"Phone":"4858D00E2B6F8B63969D1F55D5776B6D","TelPhone":null,"StateFlag":0,"IsCompany":true,"AreaID":231,"IsMaster":false,"IsCheck":true,"State":0,"Contact":"鏉庡厛鐢�","Permission":2113929216},"Msg":""}
r = requests.post(url_login, data=data, headers=headers)
print r.status_code
print r.content
print r.headers
f_cookies = r.cookies
result = r.json()
print result
print result.get('IsOk')
print result['Data']['Contact']


url_post = 'http://post.58guakao.com/Publish/Pid59Insert?InfoType=0&SubjectPid=59&SubjectId=571'


publish_data = {
            'EnterFlag': '5',
            'title': '急招注册岩土（退休也可）若干名..',
            'AreaId': '109',
            'RegType': '3',
            'Salary': '0',
            'ProfTitleLv': '0',
            'ProfTitle': '279',
            'Content': '江苏无锡勘测院，急招注册岩土（退休也可）若干名，初转不限，3年一次付，退休也可，只挂证，不挂章',
            'IsShowPhone': 'on',
        }

r = requests.post(url=url_post, data=publish_data, cookies=f_cookies, headers=headers)
print r.status_code
# print r.content
print r.text